﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 携程辅助
/// </summary>
public class CoroutineHelper : Singleton<CoroutineHelper>
{
    /// <summary>
    /// 延迟执行（秒）
    /// </summary>
    /// <param name="time">延迟时间</param>
    /// <param name="action">执行方法</param>
    /// <returns></returns>
    public Coroutine Delay(float time, Action action)
    {
        return StartCoroutine(Utility.Coroutine.Delay(time, action));
    }

    /// <summary>
    /// 当前帧的最后执行
    /// </summary>
    /// <param name="action">执行方法</param>
    /// <returns></returns>
    public Coroutine DelayEndFrame(Action action)
    {
        return StartCoroutine(Utility.Coroutine.DelayEndFrame(action));
    }

    /// <summary>
    /// 每秒执行
    /// </summary>
    public Coroutine UpdateOnSecond(Action action)
    {
        return StartCoroutine(Utility.Coroutine.Update(1, action));
    }
    public Coroutine Run(IEnumerator itor)
    {
        return StartCoroutine(itor);
    }
    public void Stop(IEnumerator itor)
    {
        StopCoroutine(itor);
    }
    public void Stop(Coroutine itor)
    {
        StopCoroutine(itor);
    }
}
